#include "Renderer.h"
#include "Window.h"

namespace SDL
{
    Renderer::Renderer(/* args */)
        : gRenderer(NULL), gWindow(NULL)
    {
    }

    Renderer::~Renderer()
    {
        if (gRenderer != NULL)
        {
            SDL_DestroyRenderer(gRenderer);
            gRenderer = NULL;
        }
    }

    bool Renderer::init(const Window &window)
    {
        gWindow = window.getSDLWindow();
        gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
        if (gRenderer == NULL)
        {
            return false;
        }
        return true;
    }

    void Renderer::setRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    {
        SDL_SetRenderDrawColor(gRenderer, r, g, b, a);
    }
    void Renderer::clear() { SDL_RenderClear(gRenderer); }
    void Renderer::flip() { SDL_RenderPresent(gRenderer); }
    SDL_Renderer *Renderer::getSDLRenderer() const { return gRenderer; }
} // namespace SDL
